<!--
  @author nowind
  @since 17/07/23 14:34
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common::jscss"/>
<title>新增或编辑产品</title>
</head>
<body>
<div class="layui-fluid">
    <blockquote class="layui-crumb">
        后台产品>产品管理>
        <a lay-href="/product/list.action">后台产品管理</a>
        <zmn th:text="(${servProductVO.name} == null) ? '' : '>' + ${servProductVO.name}">名称</zmn>
    </blockquote>

    <div class="layui-card">
        <div th:replace="product/_tab::tab"></div>

        <div class="layui-card-body">

            <form method="post" action="" class="layui-form" lay-filter="zmn-form">

                <input type="hidden" name="productId" th:value="${servProductVO.productId}"/>
                <input type="hidden" name="productType" th:value="${servProductVO.productType}"/>

                <div class="layui-card-header" style="margin-top:10px;"><b>基本信息</b></div>

                <div class="layui-form-item" th:if="${servProductVO.productId > 0}">
                    <label class="layui-form-label">产品ID：</label>
                    <div class="layui-input-block">
                        <div class="layui-form-mid">
                            <span th:text="${servProductVO.productId}">ID</span>
                            <span th:text="${servProductVO.status == 2 ? '上架' : '下架'}">status</span>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item" th:if="${servProductVO.productType == 2}">
                    <label class="layui-form-label layui-form-required">使用渠道：</label>
                    <div class="layui-input-inline">
                        <select lay-filter="channelId" id="channelId" name="channelId" lay-search lay-verify="required">
                            <option value="">-选择二级渠道-</option>
                            <option th:each="channel:${channelList}" th:value="${channel.channelId}"
                                    th:selected="${servProductVO.channelId == channel.channelId}"
                                    th:text="${channel.name}"/>
                        </select>
                    </div>
                    <span class="layui-form-mid layui-word-aux">请仔细选择：新增渠道产品后，不可修改使用渠道</span>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">服务分类：</label>
                    <div class="layui-input-inline">
                        <select name="servCategId" id="servCategId" lay-filter="servCategId" lay-verify="required"
                                th:value="${servProductVO.servCategId}">
                            <option value="">请选择</option>
                            <zmn th:each="categ:${servCategories}">
                                <option th:value="${categ.categId}" th:selected="${categ.categId == servProductVO.servCategId}"
                                        th:text="${categ.name}">
                                    分类名称
                                </option>
                            </zmn>
                        </select>
                    </div>
                    <span class="layui-form-mid layui-word-aux">渠道未开通若对应产品分类，则新增的产品无法在对应渠道使用</span>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">产品分类：</label>
                    <div class="layui-input-inline">
                        <select name="categOneId" id="categOneId" lay-filter="categOneId" lay-verify="required"
                                th:value="${servProductVO.categOneId}">
                            <option value="">请选择</option>
                            <zmn th:each="basecateg:${baseCategories}">
                                <option th:value="${basecateg.key}" th:selected="${basecateg.key == servProductVO.categOneId}"
                                        th:text="${basecateg.value}">分类名称
                                </option>
                            </zmn>
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="categId" id="categId" lay-verify="required" lay-filter="categId" th:value="${servProductVO.categId}">
                            <option value="">请选择</option>
                            <zmn th:each="basecateg:${categoryVOList}">
                                <option th:value="${basecateg.categId}" th:selected="${basecateg.categId == servProductVO.categId}"
                                        th:text="${basecateg.categName}">分类名称
                                </option>
                            </zmn>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">产品名称：</label>
                    <div class="layui-input-inline" style="width: 390px">
                        <input type="text" name="name" th:value="${servProductVO.name}" placeholder="请输入产品名称"
                               lay-verify="required" autocomplete="off" class="layui-input" maxlength="50"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">前台产品：</label>
                    <div class="layui-input-inline">
                        <select name="showProductId" id="showProductId" lay-search="" lay-filter="showProductId"  lay-verify="required"
                                th:value="${servProductVO.showProductId}">
                            <option value="">请选择</option>
                            <zmn th:each="p:${showProducts}">
                                <option th:value="${p.productId}" th:selected="${p.productId == servProductVO.showProductId}"
                                        th:text="${p.name + '('+ (p.status== 2 ? '上架' : '下架')+')'}">前台产品
                                </option>
                            </zmn>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">计价器产品：</label>
                    <div class="layui-input-inline">
                        <select name="tariffProductId" id="tariffProductId" lay-search="" lay-filter="tariffProductId" th:value="${servProductVO.tariffProductId}">
                            <option value="">请选择</option>
                            <zmn th:each="p:${tariffProducts}">
                                <option th:value="${p.productId}" th:selected="${p.productId == servProductVO.tariffProductId}"
                                        th:text="${p.name + '('+ (p.status== 2 ? '上架' : '下架')+')'}">计价器产品
                                </option>
                            </zmn>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">计价器名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="tariffName" autocomplete="off" maxlength="50" class="layui-input" th:value="${servProductVO.tariffName}"
                               lay-verify="required">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">计价器状态：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="tariffStatus" value="2" title="启用" th:checked="${servProductVO.tariffStatus == 2}">
                        <input type="radio" name="tariffStatus" value="1" title="停用"
                               th:checked="${servProductVO.productId == null||servProductVO.productId == 0||servProductVO.tariffStatus == null||servProductVO.tariffStatus == 1}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">故障分组：</label>
                    <div class="layui-input-inline">
                        <select name="faultGroupId" id="faultGroupId" lay-search="" lay-filter="faultGroupId" lay-verify=""
                                th:value="${servProductVO.faultGroupId}">
                            <option value="">请选择</option>
                            <zmn th:each="fault:${faults}">
                                <option th:value="${fault.groupId}" th:selected="${fault.groupId == servProductVO.faultGroupId}"
                                        th:text="${fault.name}">故障分组
                                </option>
                            </zmn>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">绩效分类：</label>
                    <div class="layui-input-inline">
                        <select name="ficoCtegId" id="ficoCtegId" lay-search="" lay-verify="required" th:value="${servProductVO.ficoCtegId}">
                            <option value="">请选择</option>
                            <zmn th:each="ficoCategory:${ficoCategoryList}">
                                <option th:value="${ficoCategory.categId}" th:selected="${ficoCategory.categId == servProductVO.ficoCtegId}"
                                        th:text="${ficoCategory.name}">绩效分类
                                </option>
                            </zmn>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">保修分组：</label>
                    <div class="layui-input-inline">
                        <select name="warrantyGroupId" id="warrantyGroupId" lay-search="" lay-filter="warrantyGroupId"
                                lay-verify="" th:value="${servProductVO.warrantyGroupId}">
                            <option value="">请选择</option>
                            <zmn th:each="warranty:${warrantys}">
                                <option th:value="${warranty.groupId}" th:selected="${warranty.groupId == servProductVO.warrantyGroupId}"
                                        th:text="${warranty.name}">保修分组
                                </option>
                            </zmn>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">单位：</label>
                    <div class="layui-input-inline">
                        <select name="unit" id="unit" lay-verify="required" th:value="${servProductVO.ficoCtegId}">
                            <option value="">请选择</option>
                            <zmn th:each="ficoCategory:${unitList}">
                                <option th:value="${ficoCategory}" th:selected="${ficoCategory == servProductVO.unit}" th:text="${ficoCategory}">
                                </option>
                            </zmn>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">业务类型：</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="bizType" value="1" title="C-保外业务"
                               th:checked="${servProductVO.bizType != null && servProductVO.bizType.indexOf('1') != -1}">
                        <input type="checkbox" name="bizType" value="2" title="F-保内业务"
                               th:checked="${servProductVO.bizType != null && servProductVO.bizType.indexOf('2') != -1}">
                        <input type="checkbox" name="bizType" value="3" title="B-工程业务"
                               th:checked="${servProductVO.bizType != null && servProductVO.bizType.indexOf('3') != -1}">
                    </div>
                </div>

<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label layui-form-required">展示平台：</label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <zmn th:if="${servProductVO.productId < 1}">-->
<!--                            <input type="checkbox" name="showPlat" value="10" title="啄木鸟"-->
<!--                                   th:checked="true">-->
<!--                        </zmn>-->
<!--                        <zmn th:if="${servProductVO.productId > 0}">-->
<!--                            <input type="checkbox" name="showPlat" value="10" title="啄木鸟"-->
<!--                                   th:checked="${servProductVO.showPlat != null && servProductVO.showPlat.indexOf('10') != -1}">-->
<!--                        </zmn>-->
<!--                        <input type="checkbox" name="showPlat" value="20" title="言而有信"-->
<!--                               th:checked="${servProductVO.showPlat != null && servProductVO.showPlat.indexOf('20') != -1}">-->
<!--                        <input type="checkbox" name="showPlat" value="40" title="川南环保"-->
<!--                               th:checked="${servProductVO.showPlat != null && servProductVO.showPlat.indexOf('40') != -1}">-->
<!--                        <input type="checkbox" name="showPlat" value="30" title="一步生活"-->
<!--                               th:checked="${servProductVO.showPlat != null && servProductVO.showPlat.indexOf('30') != -1}">-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">状态：</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="2" title="上架" th:checked="${servProductVO.status == 2}">
                        <input type="radio" name="status" value="1" title="下架"
                               th:checked="${servProductVO.status == 1 || servProductVO.productId == null }">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">排序：</label>
                    <div class="layui-input-inline">
                        <input type="number" name="sort" autocomplete="off" value="1000" class="layui-input" th:value="${servProductVO.sort}"
                               lay-verify="isPositiveNumber|required|minSort"  onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')">
                    </div>
                </div>

                <!--<div class="layui-form-item">-->
                    <!--<label class="layui-form-label layui-form-required">外部可见：</label>-->
                    <!--<div class="layui-input-block">-->
                        <!--<input type="radio" name="outsideUse" value="2" title="是"-->
                               <!--th:checked="${servProductVO.outsideUse == 2 || servProductVO.productId == null}">-->
                        <!--<input type="radio" name="outsideUse" value="1" title="否"-->
                               <!--th:checked="${servProductVO.outsideUse == 1}">-->
                    <!--</div>-->
                <!--</div>-->
                <div class="layui-card-header" style="margin-top:10px;"><b>产品属性</b></div>
                <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label"><b>属性</b></label>-->
                <!--</div>-->
                <style>
                    .layui-form-label {
                        width: 130px;
                    }

                    .layui-unselect.layui-form-radio {
                        width: 150px;
                    }
                </style>
                <div class="layui-form-item">
                    <div class="layui-input-inline">
                        <div style="width: 900px" lay-filter="attrId" id="attrId">
                        </div>
                    </div>
                </div>

                <div class="layui-card-header" style="margin-top:10px;"><b>相关说明</b></div>
                <div class="layui-form-item">
                    <label class="layui-form-label">一口价说明：</label>
                    <div class="layui-input-inline" style="width: 500px">
                    <textarea placeholder="请输入一口价说明（500字内）" maxlength="500" th:text="${priceStatement}" id="priceStatement" name="priceStatement"
                              class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">服务说明：</label>
                    <div class="layui-input-inline" style="width: 500px">
                    <textarea placeholder="请输入服务说明（500字内）" maxlength="500" th:text="${servProductVO.serviceDesc}" id="serviceDesc" name="serviceDesc"
                              class="layui-textarea"></textarea>
                    </div>
                </div>

                <zmn th:if="${servProductVO.productId > 0}">
                    <div class="layui-card-header layui-margin-b"><b>其他信息</b></div>

                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">修改人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux"
                                 th:text="${servProductVO.updater} + '&nbsp;/&nbsp;' + ${#dates.format(servProductVO.updateTime, 'yyyy-MM-dd HH:mm:ss')}">
                                修改人/时间
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-item-sm">
                        <label class="layui-form-label">创建人/时间：</label>
                        <div class="layui-input-block">
                            <div class="layui-form-mid layui-word-aux"
                                 th:text="${servProductVO.creater} + '&nbsp;/&nbsp;' + ${#dates.format(servProductVO.createTime, 'yyyy-MM-dd HH:mm:ss')}">
                                创建人/时间
                            </div>
                        </div>
                    </div>
                </zmn>

                <div class="layui-form-item submit">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="zmn-form-submit"
                                th:if="${#authPermit.checkPermit('/product/addEdit.action')}">保存
                        </button>
                        <button type="reset" class="layui-btn layui-btn-primary"
                                onclick="parent.layui.element.tabDelete('layadmin-layout-tabs', window.location.pathname + window.location.search)">取消
                        </button>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript" th:inline="javascript">
    var json = {
        servProductVO: [[${servProductVO}]],
        attrList: [[${attrList}]],
        channelList: [[${channelList}]]
    };
    layui.config({
        version: 201909090773,
        base: "/static/lay/"
    }).extend({
        index: "lib/index",
        product_edit_js: "product/zmn.plat.product.edit"
    }).use(['index', 'product_edit_js']);
</script>